package com.formulario.util;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

public class FormTextWatcher implements TextWatcher {
	
    private Context context;
    private EditText editText;
    private String strNameDesiredFile;
    private String strKeyText;
    
    public FormTextWatcher(Context context, EditText editText, String strNameDesiredFile, String strKeyText) {
        this.context = context;
        this.editText = editText;
        this.strNameDesiredFile = strNameDesiredFile;
        this.strKeyText = strKeyText;
    }
    
    public void afterTextChanged(Editable s) { }
    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        SharedPreferences preferencias = context.getSharedPreferences(strNameDesiredFile, Context.MODE_PRIVATE);
        Editor editor = preferencias.edit();
        editor.putString(strKeyText, editText.getText().toString());
        editor.commit();
    }
}